const importDataMixins = {
  data() {
    return {
      listData: [],
      currentFileId: ''
    }
  },
  methods: {
    cancel() {
      this.$router.back(-1)
    },
    submitData() {
      let {importDataFun, listData: importData, currentFileId: fileId} = this
      let owner = this
      this.startLoading('正在加载....')
      importDataFun({importData, fileId}).then(res => {
        owner.$modal.msgSuccess('导入任务创建成功')
      }).finally(() => {
        owner.endLoading();
        owner.cancel()
      })
    },
    getListData() {
      let {currentFileId: fileId, getDataListFun} = this;
      let owner = this
      this.startLoading('正在加载....')
      getDataListFun({fileId}).then(res => {
        owner.listData = res.data
        if (owner.setTableData != null && typeof owner.setTableData == 'function') {
          owner.setTableData(owner.listData)
        }
      }).finally(() => {
        owner.endLoading();
      })
    }
  },
  created() {
    this.currentFileId = this.$route.query?.fileId != null && this.$route.query?.fileId !== '' ? this.$route.query.fileId : null;
    this.getListData()
  }
}
export {importDataMixins}
